<template>
    <div class="test">
        <h2>{{ msg }}</h2>
        <h2>学生姓名:{{name}}</h2>
        <h2>学生年龄:{{age}}</h2>
        <button @click="sendStudentName">传递学生名给App</button>
        <button @click="unbind">解绑事件</button>
        <button @click="death">销毁当前student组件实例对象</button>
    </div>
</template>

<script>
    export default {
        name:'Student',
        data() {
            return {
                msg:'个人信息',
                name:'trent',
                age:18
            }
        },
        methods:{
            sendStudentName(){
                this.$emit('atrent',this.name)
                // this.$emit('demo')
            },
            unbind(){
                // this.$off('atrent')//解绑单个自定义事件
                // this.$off(['atrent','demo'])//解绑多个
                this.$off()//解绑所有自定义事件
            },
            death(){
                this.$destroy()
            }
        }
    }
</script>

<style scoped>
    .test{
        background-color: pink;
        padding: 5px;
        margin-top: 30px;
    }
</style>